package cn.edu.gdgm.system.job;

import org.quartz.*;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author quan
 * @date 2021-02-26
 */
public class HelloJob implements Job {
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("当前时间：" + simpleDateFormat.format(date));
        System.out.println("-----------------------------");

        JobKey key = jobExecutionContext.getJobDetail().getKey();
        System.out.println("job的name：" + key.getName());
        System.out.println("job的group：" + key.getGroup());

        JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
        System.out.println("参数openid：" + jobDataMap.getString("openid"));
        System.out.println("参数name：" + jobDataMap.getString("name"));
        System.out.println("-----------------------------");

        System.out.println("模拟向mqtt服务器发送publish...");


        // Trigger trigger = jobExecutionContext.getTrigger();
        // System.out.println("start time: " + trigger.getStartTime());
        // System.out.println("end time: " + trigger.getEndTime());

    }
}
